﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Grammar Test</title>
    <script language="javascript" type="text/javascript" src="file:///%%GI_FOLDER_PATH%%GrammarIntelliForJS.js"></script>
    <script language="javascript" type="text/javascript" src="file:///%%GI_FOLDER_PATH%%GrammarIntelliForJsUIHelper.js"></script>
    <script language="javascript" type="text/javascript">
        var oUIHelper = null;
        
        %%GI_MACHINE_DEFINITION%%
        

        function ShowMachineInfo() {
            var oInputControl = document.getElementById("txtUserInput");
            oUIHelper = new GIUIHelper(oInputControl, oGIMachine);
            oUIHelper.Initialize();

            // In case you want to customize the size of suggestions box ..like assigning a css classname or setting width ..here's how you can do
            
        }

        function ParseText() {
            oUIHelper.Hide();
            
            //NOTE: you can place a textarea & use it's id in oTrace ... tracing result will be dumped into the textarea
            
            var sKey, sText = document.getElementById("txtUserInput").value, oDiv = document.getElementById("divParseOutput"), /*oTrace = document.getElementById("txtOutput"), */ oMatchCollection = null, sHTML ="";
            //oMatchCollection = oGIMachine.ProcessText(sText, oTrace); // uncomment this if you have the trace textarea
            oMatchCollection = oGIMachine.ProcessText(sText);

            if (oMatchCollection != null) {
                var sCustomerName = "";
                // Now, its time to get the result ... 
                if(oMatchCollection.NamedMatches != null)
                {
                    for (sKey in oMatchCollection.NamedMatches) {
                        sHTML += "<b>" + sKey + "</b> = " + oMatchCollection.NamedMatches[sKey].Value + "<br>";
                    }
                }
                
                oDiv.innerHTML = sHTML;
            } else {
                oDiv.innerHTML = "No matches...";
            }
        }
        
    </script>
</head>
<body onload="ShowMachineInfo();">
    <h1>GIVisualEditor - Grammar Test [AutoGenerated]</h1>
    <h3>Try typing according to pattern based on the grammar image shown below</h3>
    <h4>Use Esc to hide suggestion, Up/Down arrow to traverse suggestions, Enter to select a suggestion. You can also use mouse</h4>
    <input type="text" id="txtUserInput" size="60" />&nbsp;<input type="button" value="Parse" onclick="ParseText();" /><br />

    <div id="divParseOutput"></div>
       
    Grammar being tested:<br />
    <img src="%%GRAMMAR_IMAGE_PATH%%" />
</body>
</html>
